//
//  DemoModel.m
//  TYUIKit_Example
//
//  Created by 谢航宇_WORK on 2022/3/16.
//  Copyright © 2022 谢航宇. All rights reserved.
//

#import "DemoModel.h"
#import "TYIOSVersionSetting.h"
@implementation DemoModel
- (instancetype)initWithString:(NSString *)string {
    self = [super init];
    if (self) {
        self.text = string;
        NSLog(@"自身初始化:%@",self.text);
    }
    return self;
}

@end


@interface DemoModel (DemoModel1)
- (instancetype)initWithString1:(NSString *)string;
@end

@implementation DemoModel (DemoModel1) 

+ (void)load{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSLog(@"方法交换1");
        [[self class]ty_swizzleInstanceMethod:@selector(initWithString:) with:@selector(initWithString1:)];
    });
}
 
- (instancetype)initWithString1:(NSString *)string {
    self.text = @"方法交换1";
    NSLog(@"自身初始化:%@",self.text);
    self = [self initWithString1:string];
    return self;
}
@end

@interface DemoModel (DemoModel2)
- (instancetype)initWithString2:(NSString *)string;
@end

@implementation DemoModel (DemoModel2)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSLog(@"方法交换2");
        [[self class]ty_swizzleInstanceMethod:@selector(initWithString:) with:@selector(initWithString2:)];
    });
}
 
- (instancetype)initWithString2:(NSString *)string {
    self.text = @"方法交换2";
    NSLog(@"自身初始化:%@",self.text);
    self = [self initWithString2:string];
    return self;
}
@end
